package guis;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.catalina.Session;

import connectionPool.PoolException;

import sql.SQLs;

/**
 * Servlet implementation class KommentarSetzten
 */
@WebServlet("/KommentarSetzten")
public class KommentarSetzten extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public KommentarSetzten() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		try {
			SQLs.update("FK_Kommentar", "feedback", "`feedback`.`FK_Teilnahme` = " + session.getAttribute("teilnahmeID") + " AND `feedback`.`FeedbackID` = " + session.getAttribute("FeedbackID"), request.getParameter("kommentar"));
		} catch (PoolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("/SVNFeedbackTool/AuswertungErzeugenFeedbackAuflistung.jsp");
	}

}
